#include <bits/stdc++.h>

#define eb emplace_back
#define ep emplace
#define fi first
#define se second
#define in read<int>()
#define lin read<ll>()
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using vec = vector < int >;
using veg = vector < pii >;

template < typename T > T read() {
	T x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-', ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

template < typename T > void chkmax(T &x, const T &y) { x = x > y ? x : y; }
template < typename T > void chkmin(T &x, const T &y) { x = x < y ? x : y; }

const int N = 1e3 + 10;

int n, m;
int x[N];
int pot[N][N], cur[N];
bool vis[N][N];
int p[N];

priority_queue < pii > q;

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in", "r", stdin);
#endif
	n = in, m = in;
	rep(i, 1, n) {
		x[i] = in, p[i] = i;
	}
	sort(p + 1, p + n + 1, [](auto a, auto b) { return x[a] > x[b]; });
	rep(i, 1, m) cur[i] = n;
	rep(i, 1, n) {
		int t = p[i];
		bool fl = 0;
		rep(j, 1, m) if(!vis[j][x[t]]) { fl = true; pot[t][j] = x[t]; vis[j][x[t]] = true;/*cerr << t << " " << j << " " << x[t] << endl; */ break; }
		if(!fl) return puts("No"), 0;
		rep(j, 1, m) if(!pot[t][j]) {
			while(vis[j][cur[j]]) cur[j]--;
			//cerr << t << " " << j << " " << cur[j] << endl;
			if(cur[j] < x[t]) return puts("No"), 0;
			pot[t][j] = cur[j]; vis[j][pot[t][j]] = true;
		}
	}
	puts("Yes");
	rep(i, 1, n) rep(j, 1, m) printf("%d%c", pot[i][j], " \n"[j == m]);
	return 0;
}
